package com.controller;

import com.model.SysUser;
import com.page.GenericPage;
import com.po.SysUserModifyPO;
import com.po.SysUserPO;
import com.po.SysUserQueryPO;
import com.result.Result;
import com.service.SysUserService;
import com.vo.SysUserQueryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: chihaojie
 * @Date: 2019/5/29 14:12
 * @Version 1.0
 * @Note
 */


@Api(value = "sysUserApi")
@CrossOrigin
@RestController
@RequestMapping("/sysUser")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @ApiOperation(value = "保存", httpMethod = "POST", notes = "保存")
    @RequestMapping(value = "/save", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<SysUser> save(@RequestBody SysUserPO sysUserPO) {
        return sysUserService.save(sysUserPO);
    }

    @ApiOperation(value = "删除", httpMethod = "GET", notes = "删除")
    @RequestMapping(value = "/removeById", method = RequestMethod.GET)
    public Result<Boolean> removeById(@RequestParam Long id) {
        return sysUserService.removeById(id);
    }



    @ApiOperation(value = "修改", httpMethod = "POST", notes = "修改")
    @RequestMapping(value = "/modifyById", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<Boolean> save(@RequestBody SysUserModifyPO sysUserModifyPO) {
        return sysUserService.modifyById(sysUserModifyPO);
    }


    @ApiOperation(value = "查询", httpMethod = "GET", notes = "查询")
    @RequestMapping(value = "/queryById", method = RequestMethod.GET)
    public Result<SysUserQueryVO> queryById(@RequestParam Long id) {
        return sysUserService.queryById(id);
    }

    @ApiOperation(value = "查询所有", httpMethod = "POST", notes = "查询所有")
    @RequestMapping(value = "/queryAll", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<GenericPage<SysUserQueryVO>> queryAll(@RequestBody SysUserQueryPO sysUserQueryPO) {
        return sysUserService.queryAll(sysUserQueryPO);
    }

}
